﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace FriendlyFire.UserControls
{
    public partial class Video : UserControl
    {
        //vars
        private Helper myHelper;
        private FriendlyFire myParent;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ffHelper">reference to friendly fire helper</param>
        public Video(ref Helper ffHelper, FriendlyFire parent)
        {
            InitializeComponent();
            myHelper = ffHelper;
            myParent = parent;
        }
        #region Video Panel Drag/Drop
        /// <summary>
        /// Handles dragdrop events onto the player
        /// </summary>
        /// <param name="sender">Object sending the event</param>
        /// <param name="e">any event arguments that need to be passed</param>
        private void playerPanel_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            //TODO redo this with the same method as in 'play'
        }

        /// <summary>
        /// Verify the integrity of the file about
        /// to be dragged.
        /// </summary>
        /// <param name="sender">Object sending the event</param>
        /// <param name="e">any event arguments that need to be passed</param>
        private void playerPanel_DragEnter(object sender, DragEventArgs e)
        {
            //check to see if the file being dragged is a valid one
            if (e.Data.GetDataPresent(DataFormats.FileDrop, true) == true)
            {
                e.Effect = DragDropEffects.All;
            }
        }
        #endregion

        /// <summary>
        /// Custom paint function for the player panel
        /// </summary>
        /// <param name="sender">Object sending the event</param>
        /// <param name="e">any event arguments that need to be passed</param>
        private void playerPanel_Paint(object sender, PaintEventArgs e)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);            
        }

        /// <summary>
        /// Event fired when teh video is resized, keeps the program from crashing and makes sure it draws properly.
        /// </summary>
        private void Video_Resize(object sender, EventArgs e)
        {
            playerPanel.Height = this.Size.Height - 32;
            playerPanel.Width = this.Size.Width;
            pictureBox1.Height = this.Size.Height - 32;
            pictureBox1.Width = this.Size.Width;
        }


    }
}
